﻿package com.wandian.util
{
	import flash.geom.Point;
	/**   
	* @author long
	* @QQ 108232706
	* @version 1.0   
	*/   
	public class CLZMath extends Object
	{

		public function CLZMath()
		{
			return;
		} 

		public static function rotatePos(param1:Number, param2:Number, param3:Number, param4:Number, param5:Boolean):Point
		{
			var _loc_6:*=new Point();
			if (param5)
			{
				_loc_6.x=param1 * param4 + param2 * param3;
				_loc_6.y=param2 * param4 - param1 * param3;
			}
			else
			{
				_loc_6.x=param1 * param4 - param2 * param3;
				_loc_6.y=param2 * param4 + param1 * param3;
			}
			return _loc_6;
		} 

		public static function getDistance(param1:Number, param2:Number, param3:Number, param4:Number):Number
		{
			return Point.distance(new Point(param1, param2), new Point(param3, param4));
		} 

		public static function getRadian(param1:Number, param2:Number, param3:Number, param4:Number):Number
		{
			var _loc_5:*=param1 - param3;
			var _loc_6:*=param2 - param4;
			return Math.atan2(_loc_6, _loc_5);
		} 

		public static function getRadianByAngle(param1:Number):Number
		{
			return Math.PI * param1 / 180;
		} 

		public static function getAngle(param1:Number, param2:Number, param3:Number, param4:Number):Number
		{
			return getAngleByRadian(getRadian(param1, param2, param3, param4));
		} 

		public static function getPlusAngle(param1:Number):Number
		{
			param1=param1 + 360;
			param1=param1 % 360;
			return param1;
		} 

		public static function getHalfAngle(param1:Number):Number
		{
			param1=param1 % 360;
			if (param1 > 180)
			{
				param1=param1 - 360;
			}
			else if (param1 < -180)
			{
				param1=param1 + 360;
			}
			return param1;
		} 

		public static function getAngleByRadian(param1:Number):Number
		{
			return 180 * param1 / Math.PI;
		} 

		public static function precision(param1:Number, param2:Number=10):Number
		{
			if (isNaN(param1))
			{
				return 0;
			}
			return Number(param1.toFixed(param2));
		} 

		public static function isInCircle(param1:Number, param2:Number, param3:Number, param4:Number, param5:Number):Boolean
		{
			return getDistance(param1, param2, param3, param4) <= param5;
		} 

		public static function isInRect(param1:Number, param2:Number, param3:Number, param4:Number, param5:Number, param6:Number):Boolean
		{
			var _loc_7:*=Math.abs(param1 - param3);
			var _loc_8:*=Math.abs(param2 - param4);
			if (_loc_7 <= param5 / 2)
			{
			}
			return _loc_8 <= param6 / 2;
		} 

		public static function momentumConservation(param1:Number, param2:Number, param3:Number, param4:Number):Array
		{
			var _loc_5:*=param1 - param2;
			param1=((param3 - param4) * param1 + 2 * param4 * param2) / (param3 + param4);
			param2=_loc_5 + param1;
			return [param1, param2];
		} 

		public static function getRandom(param1:Number, param2:Number):Number
		{
			return Math.random() * (param2 - param1) + param1;
		} 

	}
}
